#include "gdrprintvisitor.h"
#include <sstream>
#include <vector>
#include <iterator>
#include <string>

using namespace std;
using namespace opsrc::stdf;

const string listsep = "|";

GdrPrintVisitor::GdrPrintVisitor() {
}

GdrPrintVisitor::~GdrPrintVisitor() {
}


string GdrPrintVisitor::operator()(const unsigned int& val) const {
        std::stringstream stm;
	stm << val;
	return stm.str();	
}


string GdrPrintVisitor::operator()(const signed int& val) const {
        std::stringstream stm;
	stm << val;
	return stm.str();	
}

string GdrPrintVisitor::operator()(const long& val) const {
        std::stringstream stm;
	stm << val;
	return stm.str();	
}

string GdrPrintVisitor::operator()(const float& val) const {
        std::stringstream stm;
	stm << val;
	return stm.str();	
}

string GdrPrintVisitor::operator()(const double& val) const {
	std::ostringstream stm;
	stm << val;
	return stm.str();	
}

string GdrPrintVisitor::operator()(const std::string& val) const {
	return val;	
}

/*
string GdrPrintVisitor::operator()(const CharArray& val) const {
	if (val.getSize()>0 ) {
                std::stringstream stm;
		char *p = val.getBuffer();
		for ( int i=0; i<val.getSize(); i++ ) {
			int d = static_cast<int> (*(p+i));
			stm << d;
			
			if (i< val.getSize() -1 )
                          stm << listsep ;
		}
		
		return stm.str();
	}
	else {
		return "";
	} 
}



string GdrPrintVisitor::operator()(const vector<int> &val) const {
	if ( ((int)val.size()) > 0 ) {
                std::stringstream stm;
                vector<int>::const_iterator iter ;
                int c = 0;
		for ( iter = val.begin(); iter!=val.end(); iter++, c++ ) {
			stm << *iter;
			
			if (c < ((int)val.size())-1 )
                          stm << listsep ;
		}
		
		return stm.str();
	}
	else {
		return "";
	} 	
}

string GdrPrintVisitor::operator()(const vector<bool> &val) const {
	
	if ( ((int)val.size())>0 ) {
                std::stringstream stm;
                vector<bool>::const_iterator iter ;
		int c = 0;
		for ( iter = val.begin(); iter!=val.end(); iter++, c++ ) {
			stm << (*iter==true? 1: 0);
			
			if (c < ((int)val.size())-1 )
                          stm << listsep ;
		}
		
		return stm.str();
	}
	else {
		return "";
	} 		

}
*/


